package com.yunao.commons.serachcore.core.bean;



import com.yunao.commons.serachcore.utils.Constants;

import java.util.List;

import static java.util.stream.Collectors.joining;

public class BaseEntities {

	private Long status;
	private String msg;

	public Long getStatus() {
		if (status == null) {
			status = Constants.STATUS_TRUE;
		}
		return status;
	}

	public void setStatus(Long status) {
		this.status = status;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	protected <T> String toString(long total, long size, List<T> data) {
		StringBuilder res = new StringBuilder("total: " + total 
				+ ", size: " + size + "\n");
		if (data != null && !data.isEmpty()) {
			String datastr = data.stream()
					.map(String::valueOf)
					.collect(joining("\n"));
			res.append(datastr);
		}
		return res.toString();
	}

}
